﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Data;

using System.Data.SqlClient;
using MyHotel_DTO;
using MyHotel_Common;

namespace MyHotel_DAO
{
    public class DanhMucPhongDAO : DAO
    {
        protected override object createObjectFromDatarow(DataRow row)
        {
            Danhmucphong danhmucphong = new Danhmucphong();
            danhmucphong.Tenphong = row["TenPhong"].ToString();
            danhmucphong.Loaiphong = row["TenLoai"].ToString();
            danhmucphong.Dongia = Convert.ToInt32(row["Dongia"]);
            danhmucphong.Ghichu = row["GhiChu"].ToString();
            danhmucphong.MaPhong = Convert.ToInt32(row["MaPHG"]);
            return danhmucphong;
        }
        
        public List<Danhmucphong> getListDanhMucPhong(int maloai)
        {
            string namProc = "usp_laydanhsachdanhmucphong";
            SqlParameter para = new SqlParameter("@maloai", maloai);
            DataTable dt = DataProvider.executeStoreProcedureQuery(namProc, para);

            return getListFromDataTable<Danhmucphong>(dt);
        }

        public List<Danhmucphong> getListDanhMucPhong()
        {
            string namProc = "usp_Lay_DanhSach_DanhMucPhong";
            DataTable dt = DataProvider.executeStoreProcedureQuery(namProc, null);

            return getListFromDataTable<Danhmucphong>(dt);
        }
    }
}
